-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Signal controlling constants for windows #1626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @gnzlbg (rust_highfive has picked a reviewer for you, use r? to override) |
SIG_DFL and similar. Closes #1600.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @retep998 could you review as well?
@@ -465,7 +465,9 @@ fn test_windows(target: &str) { | |||
match name { | |||
// FIXME: API error: | |||
// SIG_ERR type is "void (*)(int)", not "int" | |||
"SIG_ERR" => true, | |||
"SIG_ERR" | | |||
// Similar for SIG_DFL/IGN/GET/SGE/ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add them with the right type ?
@@ -233,7 +233,13 @@ pub const SIGSEGV: ::c_int = 11; | |||
pub const SIGTERM: ::c_int = 15; | |||
pub const SIGABRT: ::c_int = 22; | |||
pub const NSIG: ::c_int = 23; | |||
|
|||
pub const SIG_ERR: ::c_int = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define SIG_ERR ((_crt_signal_t)-1)
Also libc
defines sighandler_t
as usize
when in reality it is:
typedef void (__CRTDECL* _crt_signal_t)(int);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also libc defines sighandler_t as usize when in reality it is:
typedef void (__CRTDECL* _crt_signal_t)(int);
I'll take a PR to fix this, but I'll prefer if this change were in a different PR, and not here. We probably need to do a crater run while rolling in this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just keep in mind we can't naively use extern "C" fn(c_int)
as the type because SIG_DFL
has a value of 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need Option<extern "C" fn(c_int) -> ()>
or similar (I'm not sure what to do about the __CRTDECL
or whether extern "system"
or some other ABI has to be used for windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__CRTDECL
is __cdecl
which is extern "cdecl"
or extern "C"
. Most of the CRT uses __CRTDECL
.
Hello To be honest, I'm a bit lost here what the next steps from me should be. I can go and send a pull request, changing the type. However, there are few issues.
|
cc @rust-lang/wg-unsafe-code-guidelines |
If only Rust had raw function pointers. |
Function pointers have to be non-null and aligned. While it seems unlikely that we'll ever have a platform where the alignment requirement is non-trivial, that's also not excluded currently. Cc rust-lang/unsafe-code-guidelines#197 |
Reading the guide and considering this is for Windows platform only, which has quite limited support for HW platforms it runs on, I think this should be safe then. I'll prepare the other PR soon. |
Probably saner to use a raw pointer to an uninhabited type, since it has the same ABI as function pointers but we don't actually care about it being a callable function pointer. |
But then it wouldn't really match the correct type… and then, is it worth changing at all, instead of staying as |
How does this work in C? IIRC, C requires function pointers to be properly aligned as well, at least when you call them, right ?
I think we should move the discussion about how to "fix" the function pointer type to a different issue. This PR is not the place to do this (CI is broken right now, but once it works again, I'll merge this). |
☔ The latest upstream changes (presumably #2194) made this pull request unmergeable. Please resolve the merge conflicts. |
This is ready to merge, right, apart from rebase? |
I think so…
Except I must have deleted my fork of the repo in the meantime during some cleanup :-|. I can re-create it, but I'm afraid that'll mean a new PR :-( ‒ I don't expect github UI to handle it reappearing well. |
Indeed, it's as I expected, github didn't pick it up even if the branch has the same name. It's in #2201 now, with the same content. And apologies for the confusion :-| |
Signal controlling constants for windows This is replacement of #1626, because I have lost the repository with that branch in the meantime. The content is the same (unless I've made some mistake copying it over), just rebased onto current master.
Signal controlling constants for windows This is replacement of #1626, because I have lost the repository with that branch in the meantime. The content is the same (unless I've made some mistake copying it over), just rebased onto current master.
SIG_DFL and similar.
Closes #1600.